package com.tanhua.sso.controller;

import cn.hutool.core.convert.Convert;
import com.tanhua.sso.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 通过验证码进行登录
     *
     * @param param
     * @return
     */
    @PostMapping("/loginVerification")
    public Object login(@RequestBody Map<String, Object> param) {
        String phone = Convert.toStr(param.get("phone"));
        String code = Convert.toStr(param.get("verificationCode"));
        return this.userService.loginVerification(phone, code);
    }
}
